<template>
  <div class="irm-oper-div">
    <DictGroupComponent ref="dict">
      <DictDefineComponent dict-group="BM04002"/>
    </DictGroupComponent>
    <div class="input-div-left">
      <ToolBarComponent ref="inputBar" bar-ref-name="inputBar" min-height="170px">
        <NumberInputComponent input-name="cardNo" input-type="text" input-lable="工号" validate="textMust"/>
        <InputComponent input-name="sendDraft" input-lable="报文号"  validate="textMust"/>
        <InputComponent input-name="oriDraftNo" input-lable="原报文号"/>
        <SelectComboComponent input-name="mockType" input-lable="Mock类型" group-code="BM04002"/>
        <InputComponent input-name="memberId" input-lable="会员代码"  validate="textMust"/>
        <SelectComboComponent input-name="qmgrId" input-lable="队列管理器" group-code="BM04003"/>
        <Button text="提交" :click-function="submitIrm"/>
        <Button text="查询结果" :click-function="mockLoad"/>
      </ToolBarComponent>
      <GridComponent
          ref="mockGrid"
          :auto-load="true"
          key-property-name="id"
          grid-name="mockGrid"
          select-moduel="single"
          load-url="draft/queryMockInfo.do"
          max-height-prop="83%"
          :paging-moduel="true"
      >
        <GridColumnComponent width="150px" column-name="队列管理器ID" index-name="qmgrInfoId"/>
        <GridColumnComponent width="190px" column-name="会员名称" index-name="memberName"/>
        <GridColumnComponent width="120px" column-name="报文号" index-name="draftNo"/>
        <GridColumnComponent width="120px" column-name="原报文号" index-name="oriDraftNo"/>
        <GridColumnComponent width="150px" column-name="Mock类型" index-name="mockType" :data-render="sysParamRender"/>
        <GridColumnComponent width="150px" column-name="接入点号" index-name="meetingCode"/>
        <GridColumnComponent width="150px" column-name="会员代码" index-name="memberId"/>
      </GridComponent>
    </div>
    <div class="input-div-right">
      <!--   物品查询列表   -->
      <ToolBarComponent ref="queryBar" bar-ref-name="queryBar" min-height="170px">
        <div style="display: none">
          <InputComponent ref="group-input" input-lable="字典分组" input-name="groupCodeArr" input-type="text"/>
        </div>
        <InputComponent input-lable="报文编号" input-name="key" input-type="text"/>
        <Button text="查询" :click-function="dictQuery"/>
      </ToolBarComponent>
      <GridComponent
          ref="cpesDraftGrid"
          :auto-load="false"
          key-property-name="key"
          grid-name="cpesDraftGrid"
          select-moduel="single"
          load-url="dict/getDictList.do"
          max-height-prop="83%"
          :paging-moduel="false"
      >
        <GridColumnComponent width="220px" column-name="报文序号" index-name="key"/>
      </GridComponent>
    </div>
  </div>
</template>

<script>
import InputComponent from "@/components/input/InputComponent";
import NumberInputComponent from "@/components/input/NumberInputComponent";
import SelectComboComponent from "@/components/input/SelectComboComponent";
import GridComponent from "@/components/grid/GridComponent";
import GridColumnComponent from "@/components/grid/GridColumnComponent";
import ToolBarComponent from "@/components/toolbar/ToolBarComponent";
import Button from "@/components/button/ButtonComponent";
import {postRequest} from "@/axio2";
import {translateByDict} from "@/common-util";
import DictGroupComponent from "@/components/dict/DictGroupComponent";
import DictDefineComponent from "@/components/dict/DictDefineComponent";

export default {
  name: "IrmOper",
  components: {
    DictDefineComponent,
    DictGroupComponent,
    ToolBarComponent, Button,
    GridColumnComponent, GridComponent, SelectComboComponent, NumberInputComponent, InputComponent
  },
  methods: {
    mockLoad(){
      this.$refs["mockGrid"].addQueryParams({});
      this.$refs["mockGrid"].load();
    },
    dictQuery(){
      let param = this.$refs["queryBar"].getSubmitParams();
      this.$refs["cpesDraftGrid"].addQueryParams(param);
      this.$refs["cpesDraftGrid"].load();
    },
    submitIrm(){
      let param = this.$refs["inputBar"].getSubmitParams();
      postRequest(
          'draft/oper.do',
          param,
          this.addSuccess,
          null,
          this
      )
    },
    addSuccess(response,component){
      component.$refs["mockGrid"].addQueryParams({});
      component.$refs["mockGrid"].load();
    },
    sysParamRender(columnData){
      return translateByDict(columnData,this.$refs["dict"].getDictGroup("BM04002"));
    }
  },
  mounted() {
    this.$refs["group-input"].setInputValue("BM04001");
  }
}
</script>

<style scoped>
.input-div-left{
  width: 74%;
  height: 90%;
  display: inline-block;
  vertical-align: top;
}
.input-div-right{
  width: 23%;
  height: 90%;
  display: inline-block;
  vertical-align: top;
}
.irm-oper-div{
  height: 98%;
  overflow: auto;
  vertical-align: top;
}
</style>